package com.gdust.gkyx.search.repository;

import com.gdust.gkyx.model.search.SkuEs;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;


/**
 * ClassName: SkuRepository
 * Package: com.gdust.gkyx.search.repository
 * Description:商品搜索相关的Elasticsearch仓库接口，用于查询和分页操作
 *
 * @Author syun
 * @Create 2025/1/26 11:12
 * @Version 1.0
 */
public interface SkuRepository extends ElasticsearchRepository<SkuEs,Long> {

    /**
     * //获取爆款商品
     * @param pageable 分页对象
     * @return
     */
    Page<SkuEs> findByOrderByHotScoreDesc(Pageable pageable);

    /**
     * //// 判断keyword是否为空，如果为空 ，根据仓库id + 分类id查询
     * @param categoryId 商品分类的ID
     * @param wareId 仓库的ID
     * @param pageable 分页对象
     * @return
     */
    Page<SkuEs> findByCategoryIdAndWareId(Long categoryId, Long wareId, Pageable pageable);

    /**
     * ///如果keyword不为空根据仓库id + keyword进行查询
     * @param keyword 商品关键字
     * @param wareId 仓库的ID
     * @param pageable 分页对象
     * @return
     */
    Page<SkuEs> findByKeywordAndWareId(String keyword, Long wareId, Pageable pageable);
    //List<SkuEs> findByOrderByHotScoreDesc();
}
